home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / spool.zip / BUFFERP.ASM next >
Assembly Source File  |  1985-08-09  |  15KB  |  730 lines

  1. ; PRINT control program
  2.  
  3.     page 60,132
  4.  
  5. ;Routines
  6.  
  7.     public    begin,s1,baddevice,b1,do_menu,b2,b23,test_end,exit8
  8.     public    clear_the_buffer,b245,b25,change_priority,b26,b265,b27
  9.     public    change_port,b3,b35,b4,exit9,lpt1,b5,lpt2,b6,lpt3,com1,com2
  10.     public    this_prn_not_avaliable,termin_ate,set_pause,get_query,no_pause
  11.     public    printbxcxdx,p1,p2,p3,p4,p5,bin2dec,repeat3,ioctl,ioctl_ret
  12.     public    get_port_address,g1,print_port,com,lpt,com_one,com_two,lpt_one
  13.     public    lpt_two,lpt_three,error3,ascbin,ab1,ab2
  14.     public    ab25,ab3,ab4,ab5,ab6
  15.  
  16. ;Variables
  17.  
  18.     public    header,not_installed,not_valid_port,pause_on,line1,line2,line3
  19.     public    line4,menu,number,port_menu,not_avaliable,pause_on_q
  20.     public    pause_off_q,buffer_cleared,new_port,lpt1_mess,lpt2_mess
  21.     public    lpt3_mess,com1_mess,com2_mess,new_priority,nothing_done
  22.     public    you_sure,crlf,space,not_valid_number,port_number,port_type
  23.     public    buffer_size,characters_in_buffer,priority,pause_flag
  24.     public    scratch,ioctl_buff,handle
  25.  
  26. code    segment
  27.     assume cs:code, ds:code, es:code, ss:code
  28.  
  29. keyboard_no_echo equ    8        ; msdos function call equates
  30. display_char    equ    2
  31. display_string    equ    9
  32. terminate    equ    4ch
  33.  
  34. cr            equ    0dh
  35. lf            equ    0ah
  36.  
  37. ;    Version 2.1    : By Craig Derouen. Change communications input from
  38. ;    3/20/85        : software interrupt to ioctl calls to make better
  39. ;            : compatability with other programs.
  40. ;    Version 2.2    : By Craig Derouen. Add printer pause feature
  41. ;    4/4/85
  42.  
  43.     org 100h
  44. begin:
  45.     jmp s1
  46. ; data
  47. header        db "BUFFER PRINT control program. Version 2.2",cr,lf,lf,"$"
  48. not_installed    db "FLASH PRINT is not installed.",cr,lf,"$"
  49. not_valid_port    db "The output port does not exist",cr,lf,"$"
  50. pause_on    db cr,lf,"The printer output is paused right now",cr,lf,"$"
  51. line1        db "The number of characters in the buffer: $"
  52. line2        db "The size of the buffer in characters: $"
  53. line3        db "The port being used with the printer: $"
  54. line4        db "The priority of the printer (1 lowest, 200 highest): $"
  55. menu        db cr,lf,"Choose the number of one of the following command options.",cr,lf
  56.         db "1.) Clear the buffer",cr,lf
  57.         db "2.) Change the port to use with the printer",cr,lf
  58.         db "3.) Change the priority",cr,lf
  59.         db "4.) Pause printer output",cr,lf
  60.         db "5.) Reprint the current page",cr,lf
  61.         db "6.) Exit the program",cr,lf,"$"
  62. number        db "Number: ","$"
  63. port_menu    db cr,lf,lf,"Choose the port to use with the printer.",cr,lf
  64.         db "1.) LPT1",cr,lf
  65.         db "2.) LPT2",cr,lf
  66.         db "3.) LPT3",cr,lf
  67.         db "4.) COM1",cr,lf
  68.         db "5.) COM2",cr,lf
  69.         db "6.) Exit the program",cr,lf,"$"
  70. not_avaliable    db "The port chosen is not in the system",cr,lf,"$"
  71. pause_on_q    db cr,lf,"Do you want to pause printer output (y=yes) ? $"
  72. pause_off_q    db cr,lf,"Do you want printer output on again (y=yes) ? $"
  73. buffer_cleared    db "The buffer is empty",cr,lf,"$"
  74. new_port    db "The new port to use with the printer is $"
  75. lpt1_mess    db "LPT1",cr,lf,"$"
  76. lpt2_mess    db "LPT2",cr,lf,"$"
  77. lpt3_mess    db "LPT3",cr,lf,"$"
  78. com1_mess    db "COM1",cr,lf,"$"
  79. com2_mess    db "COM2",cr,lf,"$"
  80. new_priority    db "Input the new priority: $"
  81. nothing_done    db "Nothing was done",cr,lf,"$"
  82. you_sure    db "You sure you what to clear the buffer? (y=yes) $"
  83. crlf        db cr,lf,"$"
  84. space        db "  $"
  85. not_valid_number db cr,lf,"invalid number",cr,lf,"$"
  86.  
  87. port_number        db ?
  88. port_type        db ?
  89. buffer_size        dw ?
  90. characters_in_buffer    dw ?
  91. priority        dw ?
  92. pause_flag        db ?
  93. ; end of data
  94.  
  95. ; macros
  96. print    macro    message
  97.     mov ah, display_string
  98.     mov dx, offset message
  99.     int 21h
  100.     endm
  101.  
  102. buffer_input    macro    size_of_buffer
  103.     local i2, buffer, num_of_chars, buffer2
  104. ; This macro inputs characters from the keyboard with echo and stores them in memory.
  105. ; The string of characters is terminated with two bytes of 0.
  106. ; enter: ds = cs
  107. ; exit: al = # of characters typed not including the CR
  108. ;    ds:si -> first char. of the string typed
  109.  
  110.     jmp i2
  111. buffer        db size_of_buffer + 1
  112. num_of_chars    db ?
  113. buffer2        db size_of_buffer dup(?)
  114.         dw ?
  115. i2:
  116.     mov ah, 0ah            ; buffer keyboard input
  117.     mov dx, offset buffer
  118.     int 21h
  119.     
  120.     mov al, [num_of_chars]        ; end the string with 0,0
  121.     mov ah, 0
  122.     mov si, offset buffer2
  123.     add si, ax
  124.     mov [si], word ptr 0
  125.     sub si, ax
  126.     
  127.     endm
  128. ; end of macros
  129.  
  130. s1:
  131.     print header            ; print "BUFFER PRINT program ..."
  132.     
  133.     mov ax,7
  134.     call ioctl            ; call driver
  135.     push bx
  136.     mov ax,8
  137.     xor bx,bx            ; do nothing
  138.     call ioctl
  139.     mov pause_flag,bl
  140.     pop bx
  141.     
  142.     jc  baddevice
  143.     cmp bx, 55aah            ; check test pattern
  144.     je  b1
  145.  
  146. baddevice:
  147.     print not_installed        ; print "BUFFER PRINT is not installed."
  148.     jmp termin_ate
  149. b1:
  150.     mov ax, cs            ; restore es = cs
  151.     mov es, ax
  152.  
  153.     mov ax, 1            ; get port # and type
  154.     call ioctl
  155.     mov [port_number], bl
  156.     mov [port_type], bh
  157.     
  158.     mov ax, 3            ; get buffer size
  159.     call ioctl
  160.     mov [buffer_size], bx
  161.     
  162.     mov ax, 4            ; get # of char. in the buffer
  163.     call ioctl
  164.     mov [characters_in_buffer], bx
  165.     
  166.     mov ax, 6            ; get the priority
  167.     call ioctl
  168.     mov [priority], bx
  169.  
  170.     print line1            ; print "The number of characters in the buffer:"
  171.     
  172.     mov ax, [characters_in_buffer]
  173.     call bin2dec
  174.     call printbxcxdx
  175.     print crlf        
  176.     
  177.     print line2            ; print "The size of the buffer in characters:"
  178.     
  179.     mov ax, [buffer_size]
  180.     call bin2dec
  181.     call printbxcxdx
  182.     print crlf
  183.     
  184.     print line3            ; print "The port being used with the printer:"
  185.     
  186.     mov ah, [port_type]
  187.     mov al, [port_number]    
  188.     call print_port
  189.     
  190.     print line4            ; print "The priority of the printer (1 lowest, 65536 highest):"
  191.     
  192.     mov ax, [priority]
  193.     call bin2dec
  194.     call printbxcxdx
  195.     print crlf
  196.     cmp pause_flag,-1        ; is printer paused ?
  197.     jne do_menu
  198.     print pause_on
  199. do_menu:
  200.     print menu            ; print the menu
  201. b2:    
  202.     print number            ; print "Number: "
  203.     
  204.     mov ah, keyboard_no_echo    ; wait for a number to be typed
  205.     int 21h
  206.  
  207.     cmp al, cr
  208.     je exit8
  209.     
  210.     push ax                ; echo every thing except cr
  211.     mov ah, display_char
  212.     mov dl, al
  213.     int 21h
  214.  
  215.     print space            ; print two spaces
  216.     pop ax
  217.     
  218.     cmp al, "1"            ; jump to the correct command
  219.     je clear_the_buffer
  220.     cmp al, "2"
  221.     jne b23
  222.     jmp change_port
  223. b23:
  224.     cmp al, "3"
  225.     je change_priority
  226.     cmp al, "4"
  227.     jne test_end
  228.     jmp set_pause            ; Handle pause status
  229. test_end:
  230.     cmp al, "5"            ; reprint current page
  231.     je print_cur_page
  232.     cmp al, "6"
  233.     je exit8
  234.     jmp b2
  235.  
  236. exit8:
  237.     print crlf
  238.     jmp termin_ate
  239.     
  240. print_cur_page:
  241.     mov    ax,9            ; current page function
  242.     xor    bx,bx
  243.     call    ioctl
  244.     jmp    termin_ate
  245.  
  246. clear_the_buffer:
  247.     print you_sure            ; print "Are you sure you want to clear the buffer? (y=yes) "
  248.     
  249.     mov ah, keyboard_no_echo    ; wait for something to be typed
  250.     int 21h
  251.  
  252.     cmp al, cr
  253.     je b245
  254.  
  255.     push ax                ; echo everything except cr
  256.     mov ah, display_char
  257.     mov dl, al
  258.     int 21h
  259.     
  260.     print space            ; print two spaces
  261.     pop ax
  262.  
  263.     and al, 0dfh            ; convert the something to upper case
  264.     
  265.     cmp al, "Y"
  266.     je b25
  267. b245:
  268.     print nothing_done        ; print "Nothing was done"
  269.     jmp termin_ate
  270. b25:    
  271.     mov ax, 0            ; flush the buffer
  272.     call ioctl
  273.  
  274.     print buffer_cleared        ; print "The buffer is empty"    
  275.     jmp termin_ate
  276.  
  277. change_priority:
  278.     print new_priority        ; print "Input the new priority"
  279.     
  280.     buffer_input  5            ; input max. of 5 character from the keyboard with echo
  281.     cmp al, 0            ; if no characters were typed exit
  282.     jnz b26
  283.     jmp termin_ate
  284. b26:    
  285.     call ascbin            ; conver the ascii characters to binary
  286.     push ax    
  287.  
  288.     print crlf
  289.  
  290.     lodsb                ; if the first non convertable character is a 0, then it was a good #.
  291.     cmp al, 0
  292.     pop ax
  293.     jnz b265
  294.  
  295.     cmp ax, 0            ; the priority must be between 1 and 200
  296.     je b265
  297.     cmp ax, 200            
  298.     ja b265
  299.     jmp b27
  300.  
  301. b265:
  302.     print not_valid_number
  303.     jmp change_priority
  304. b27:    
  305.     mov bx, ax            ; set the new priority
  306.     mov ax, 5
  307.     call ioctl
  308.  
  309.     print crlf    
  310.     jmp termin_ate
  311.     
  312. change_port:
  313.     print port_menu            ; print the port menu
  314. b3:
  315.     print number            ; print "Number: "
  316.     
  317.     mov ah, keyboard_no_echo    ; wait for a number to be typed
  318.     int 21h
  319.  
  320.     cmp al, cr
  321.     je exit9
  322.     
  323.     push ax                ; echo every thing except cr
  324.     mov ah, display_char
  325.     mov dl, al
  326.     int 21h
  327.  
  328.     print space            ; print two spaces
  329.     pop ax
  330.  
  331.     cmp al, "1"            ; jump to the correct command
  332.     je lpt1
  333.     cmp al, "2"
  334.     je lpt2
  335.     cmp al, "3"
  336.     je lpt3
  337.     cmp al, "4"
  338.     jne b35
  339.     jmp com1
  340. b35:
  341.     cmp a